package feeinterface.dao;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.ulwx.database.DataBaseSet;
import com.ulwx.tool.CTime;
import com.ulwx.tool.DbUtils;
import feeinterface.modeldb.ChannelUserSelectRecord;

public class ChannelUserSelectRecordDao {

	private static final Logger log = Logger.getLogger(ChannelUserSelectRecordDao.class);
	public static void insert(ChannelUserSelectRecord me ) {

		try {
			DbUtils.excuteInsertClass(null, me);
			//DbUtils.excuteInsertClass(null, cuscinfo);

		} catch (Exception e) {
			log.error("", e);
		}

	}
	
	public static boolean isBetween72Hours(String imsi, Integer channelid){

		String sql="select channelid from ChannelUserSelectRecord where " +
					" CreateTime >=DATE_ADD(NOW(),INTERVAL -4320 minute) and" +
					" channelid=? and imsi=? limit 1";
		Map<Integer, Object> map = new HashMap<Integer, Object>();
		map.put(1, channelid);
		map.put(2, imsi);
		try{
			DataBaseSet rs=DbUtils.doCachedQuery(null, sql, map);
			if(rs.next()){
				return true;
			}
		}catch(Exception e){
			log.error("",e);
		}
		return false;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		isBetween72Hours("460016112246492",10482);

	}

}
